﻿@{
    ViewBag.Title = SPMS.Web.Properties.Resources.text_app_title;
}

@section scripts
{
    <script type="text/javascript">

        //挂接ExtJS准备完毕事件
        Ext.onReady
        (
            function () {
                //初始化快速提示
                Ext.QuickTips.init();

                //设置状态保存提供者（当前设置为Cookie）
                Ext.state.Manager.setProvider(Ext.create('Ext.state.CookieProvider', { path: _StatePath }));

                //创建视口
                Ext.create
                (
                    'Ext.container.Viewport',
                    {
                        layout: 'border',
                        minWidth: 960,
                        minHeight: 600,
                        autoScroll: true,
                        items:
                        [
                            {
                                region: 'north',
                                contentEl: 'spms-page-header',
                                border: false,
                                margins: '0 0 0 0'
                            },
                            {
                                region: 'north',
                                contentEl: 'spms-page-login',
                                border: false,
                                margins: '0 0 0 0'
                            },
                            {
                                id: 'spms-panel-menu',
                                stateful: true,
                                stateId: 'spms-menu-state',
                                region: 'west',
                                xtype: 'treepanel',
                                margin: '0 0 0 0',
                                collapsible: false,
                                collapseMode: 'header',
                                titleCollapse: true,
                                rootVisible: false,
                                rowLines: false,
                                split: true,
                                autoScroll: 'true',
                                scroll: 'vertical',
                                iconCls: 'spms-icon-menu',
                                title: spms.resources.text_title_menubar,
                                width: 180,
                                maxWidth: 240,
                                minWidth: 160,
                                useArrows: true,
                                lines: false,
                                bodyPadding: '1 1 1 1',
                                listeners:
                                {
                                    itemclick: spms.event.OnMenuClick
                                },
                                viewConfig:
                                {
                                    stripeRows: true,
                                    loadingText: spms.resources.text_loading,
                                    singleSelect: true
                                },
                                root:
                                {
                                    root: true,
                                    expanded: true
                                },
                                store: Ext.create
                                (
                                    'Ext.data.TreeStore',
                                    {
                                        autoSync: false,
                                        autoLoad: true,
                                        remoteFilter: true,
                                        remoteSort: true,
                                        model: 'Menu',
                                        defaultRootProperty: 'data',
                                        defaultRootId: 'parentID',
                                        folderSort: false,
                                        clearOnLoad: true,
                                        filters: [{ property: "Role_Name@E", value: _CurrentRole }],
                                        sorters: [{ property: "CategoryTheOrder", direction: 'ASC' }, { property: "TheOrder", direction: 'ASC' }],
                                        proxy:
                                        {
                                            type: 'ajax',
                                            url: spms.url.Action('Get', 'Menu'),
                                            batchActions: true,
                                            listeners:
                                            {
                                                //处理代理异常
                                                exception: spms.exception.HandleProxyError
                                            }
                                        }
                                    }
                                )
                            },
                            {
                                region: 'south',
                                title: '',
                                border: false,
                                titleCollapse: true,
                                collapsible: false,
                                contentEl: 'spms-page-footer',
                                split: false,
                                margins: '3 0 0 0',
                                height: 24,
                                minHeight: 24,
                                maxHeight: 24
                            },
                            {
                                id: 'spms-panel-message',
                                margin: '0 0 0 0',
                                stateful: true,
                                stateId: 'spms-message-state',
                                xtype: 'panel',
                                region: 'east',
                                iconCls: 'spms-icon-message',
                                title: spms.resources.text_title_messagebar,
                                collapsible: false,
                                collapseMode: 'header',
                                titleCollapse: true,
                                split: true,
                                width: 140,
                                maxWidth: 160,
                                minWidth: 120
                            },
                            {
                                id: 'spms-tabpanel-pagecontainer',
                                bodyStyle: 'border:none;',
                                region: 'center',
                                border: false,
                                margin: '0 0 0 0',
                                minTabWidth: 140,
                                xtype: 'tabpanel',
                                activeTab: 0
                                //items:
                                //[
                                //    {
                                //        title: '首页',
                                //        titleAlign: 'left',
                                //        iconCls: 'spms-icon-tab-home',
                                //        html: ''
                                //    }
                                //]
                            }
                        ]
                    }
                );

                //创建导航参数
                var options =
                    {
                        url: 'Home/Main',
                        title: '首页',
                        iconCls: 'spms-icon-tab-home',
                        id: '26e9040b-2acd-4e4d-a1f1-2e9bbd255699'
                    };

                //判断是否指定了导航地址 
                if (options.url) {
                    //执行导航
                    spms.navigation.Navigate(options);
                }
            }
        );


    </script>
}